<template>
    <div>
      <div class="container">
        <h2>{{newsDetail.theme}}</h2>
        <el-divider></el-divider>
        <div>
          <span style="font-size: small;">发布时间：{{newsDetail.createTime?  newsDetail.createTime.substring(0,16) : ''}}</span>
          <span style="font-size: small;margin-left: 30px">浏览量：{{newsDetail.views}}</span>
        </div>
        <div class="detail ql-editor" v-html="newsDetail.details">

        </div>
        <el-divider class="bottom_line"></el-divider>
      </div>
    </div>
</template>

<script>

    import { getRequest } from '../../api';
    import 'quill/dist/quill.core.css';
    import 'quill/dist/quill.snow.css';
    import 'quill/dist/quill.bubble.css';

    export default {
        name: "NewsDetails",
        data(){
            return{
                newsDetail: {}
            }
        },
        methods: {
            loadNewsDetail(){
                const newsId=this.$route.query.newsId;
                const params={newsId: newsId};
                getRequest('/getNewsDetail', params).then(resp=>{
                    if(resp){
                        this.newsDetail=resp;
                    }else{
                        console.log("新闻详情页获取失败");
                    }
                })
            }
        },
        mounted() {
            this.loadNewsDetail();
        }
    }
</script>

<style scoped>
  h2{
    text-align: center;
    margin-top: 20px;
  }
  .el-divider{
    margin-bottom: 5px;
  }
  .detail{
    margin-top: 30px;
    font-size: large;
    font-family: 华光仿宋_CNKI;
    line-height: 2em;
    min-height: 500px;
    text-indent: 2em;   /* 段落缩进2格 */
  }

  .bottom_line{
    margin-top: 8px;
  }
</style>
